/*************************************************************************
    > File Name: client.cpp
    > Author: Lancer
    > Mail: 18826075768@163.com
************************************************************************/

#include <iostream>
#include <pthread.h>
#include <unistd.h>


using namespace std;

void* func(void* args){
    sleep(5);
    cout << "thread id in pthread = " << pthread_self() << endl;
    pthread_exit((void*)1);
}

int main(){
    pthread_t tid;
    int para = 2;
    int ret = pthread_create(&tid, nullptr, func, &para);

    if(ret){
        cout << "pthread_create error: ret = " << ret <<"!" <<endl;
        return ret;
    }

    cout << "thread id in process = " << tid << endl;

    void* retval;
    ret = pthread_join(tid, &retval);

    if(ret){
        cout << "pthread_join error : ret = " << ret << "!" <<endl;
        return ret;
    }

    cout << "retval = " << long(retval) << endl;
    return 0;
}